package com.cn.mmd.service;

import com.cn.mmd.mapper.*;
import com.cn.mmd.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 标签接口实现类
 * Created by Administrator on 2016/8/1.
 */

@Service("label")
public class LabelServiceImpl implements LabelService {

    @Autowired
    LabelMapper labelMapper;
    @Autowired
    LabelIndexMapper labelIndexMapper;
    @Autowired
    LabelTwoIndexMapper labelTwoIndexMapper;
    @Autowired
    LabelThreeIndexMapper labelThreeIndexMapper;
    @Autowired
    LabelPackageMapper labelPackageMapper;

    /**
     * 添加标签
     * @param label
     * @return
     */
    public int insertLabel(Label label){
        return labelMapper.insertSelective(label);
    }


    /**
     * 通过标签库名查出下面的所有一级指标名
     * @param packageName
     * @return
     */
    public List<LabelIndex> selectByPackageName(String packageName){
        return labelIndexMapper.selectByPackageName(packageName);
    }



    /**
     * 通过标签库名和一级指标名查出下面的所有二级指标名
     * @param labelTwoIndex
     * @return
     */
    public List<LabelTwoIndex> selectBylabelName(LabelTwoIndex labelTwoIndex){
        return labelTwoIndexMapper.selectByIndexName(labelTwoIndex);
    }


    /**
     * 通过条件查出下面的所有三级指标名
     * @param labelThreeIndex
     * @return
     */
    public List<LabelThreeIndex> selectByTwoLabelName(LabelThreeIndex labelThreeIndex){
        List<LabelThreeIndex> labelThreeIndexes=labelThreeIndexMapper.selectByTwoIndexName(labelThreeIndex);
        return labelThreeIndexes;
    }


    /**
     * 通过条件查出下面的所有标签
     * @param label
     * @return
     */
    public List<Label> selectByThreeLabelName(Label label){
        return labelMapper.selectByThreeIndexName(label);
    }


    /**
     * 通过一级指标查出下面所有标签
     * @param indexName
     * @return
     */
    public List<Label> selectByIndexName(String indexName){
        return labelMapper.selectByIndexName(indexName);
    }


    /**
     * 修改标签
     * @param label
     * @return
     */
    public int updateLabel(Label label){
        return labelMapper.updateByPrimaryKeySelective(label);
    }


    /**
     * 删除标签
     * @param labelId
     * @return
     */
    public int deleteLabel(int labelId){
        return labelMapper.deleteByPrimaryKey(labelId);
    }


    /**
     * 通过标签名查出指定标签
     * @param label
     * @return
     */
    public Label selectLabel(Label label){
        return labelMapper.selectAllLabel(label);
    }


    /**
     * 通过标签库名查出标签库信息
     * @param packageName
     * @return
     */
    public LabelPackage selectLabelPackage(String packageName){
        return labelPackageMapper.selectByPrimaryKey(packageName);
    }


    /**
     * 查出所有标签库
     * @param labelPackage
     * @return
     */
    public List<LabelPackage> selectAllPackage(LabelPackage labelPackage){
        return labelPackageMapper.selectAllPackage(labelPackage);
    }


    /**
     * 查出标签库数量
     * @return
     */
    public int selectPackageCount(){
        return labelPackageMapper.selectPackageCount();
    }


    /**
     * 添加标签库
     * @param labelPackage
     * @return
     */
    public int insertLabelPackage(LabelPackage labelPackage){
        return labelPackageMapper.insert(labelPackage);
    }


    /**
     * 添加一级指标
     * @param labelIndex
     * @return
     */
    public int insertOneIndex(LabelIndex labelIndex){
        return labelIndexMapper.insertSelective(labelIndex);
    }


    /**
     *通过一级指标名修改其权重
     * @param labelIndex
     * @return
     */
    public int updateByIndexName(LabelIndex labelIndex){
        return labelIndexMapper.updateByIndexName(labelIndex);
    }


    /**
     *通过二级指标名修改其权重
     * @param labelTwoIndex
     * @return
     */
    public int updateByTwoIndexName(LabelTwoIndex labelTwoIndex){
        return labelTwoIndexMapper.updateByTwoIndexName(labelTwoIndex);
    }


    /**
     * 通过三级指标名修改其权重
     * @param labelThreeIndex
     * @return
     */
    public int updateByThreeIndexName(LabelThreeIndex labelThreeIndex){
        return labelThreeIndexMapper.updateByThreeIndexName(labelThreeIndex);
    }


    /**
     * 查出index的主键
     * @param labelIndex
     * @return
     */
    public LabelIndex selectIndexId(LabelIndex labelIndex){
        return labelIndexMapper.selectIndex(labelIndex);
    }


    /**
     * 通过主键修改一级指标
     * @param labelIndex
     * @return
     */
    public int updateByindexId(LabelIndex labelIndex){
        return labelIndexMapper.updateByPrimaryKeySelective(labelIndex);
    }


    /**
     * 通过主键修改二级指标
     * @param labelTwoIndex
     * @return
     */
    public int updateByTwoIndexId(LabelTwoIndex labelTwoIndex){
        return labelTwoIndexMapper.updateByPrimaryKeySelective(labelTwoIndex);
    }


    /**
     * 通过主键修改三级指标
     * @param labelThreeIndex
     * @return
     */
    public int updateByThreeIndexId(LabelThreeIndex labelThreeIndex){
        return labelThreeIndexMapper.updateByPrimaryKeySelective(labelThreeIndex);
    }

    /**
     * 添加二级指标
     * @param labelTwoIndex
     * @return
     */
    public int insertTwoIndex(LabelTwoIndex labelTwoIndex){
        return labelTwoIndexMapper.insertSelective(labelTwoIndex);
    }

    /**
     * 添加三级指标
     * @param labelThreeIndex
     * @return
     */
    public int insertThreeIndex(LabelThreeIndex labelThreeIndex){
        return labelThreeIndexMapper.insertSelective(labelThreeIndex);
    }
}
